﻿namespace Core
{
    public class WndShowInst : Core.Component, IInstruction, IAwake<int>,
        IStartUpdateFinish
    {
        public bool IsComplete { get; protected set; }

        private int wndID;

        public void Awake(int wnd_id)
        {
            wndID = wnd_id;
        }

        public override void Dispose()
        {
            if (IsDisposed) return;
            wndID = 0;
            base.Dispose();
        }

        public void Start()
        {
            //log.err($"WndShowInst.Start");
            G.UI.Show(wndID);
            IsComplete = false;
        }

        public void Update()
        {
            if (IsComplete) return;
            var wnd = G.UI.Get(wndID);
            if (wnd.Active)
            {
                IsComplete = true;
            }
        }

        public void Finish()
        {
            //log.err($"WndShowInst.Finish");
        }
    }
}
